﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Net;
using System.IO;
using System.Text;

/// <summary>
/// Summary description for bzMyStatus
/// </summary>
public class bzMyStatus
{	
    public static bool Skype_isOnline(string nickName)
    {       
        HttpWebRequest request = null;
        request =(HttpWebRequest) HttpWebRequest.Create("http://mystatus.skype.com/" + nickName + ".num");
        request.Method = "POST";
        request.ContentType = "application/x-www-form-urlencoded";
        HttpWebResponse res = (HttpWebResponse)request.GetResponse();
        StreamReader str = new StreamReader(res.GetResponseStream(), Encoding.UTF8);
        try
        {
            return Convert.ToInt16(str.ReadToEnd().ToLower().Trim()) == 2;
        }
        catch
        {
            return false;                
        }
    }
    public static bool Yahoo_isOnline(string nickName)
    {
        HttpWebRequest request = null;
        request = (HttpWebRequest)HttpWebRequest.Create("http://opi.yahoo.com/online?u=" + nickName + "&m=t&t=1");
        request.Method = "POST";
        request.ContentType = "application/x-www-form-urlencoded";
        HttpWebResponse res = (HttpWebResponse)request.GetResponse();
        StreamReader str = new StreamReader(res.GetResponseStream(), Encoding.UTF8);
        try
        {
            return Convert.ToInt16(str.ReadToEnd().ToLower().Trim()) == 1;
        }
        catch
        {
            return false;
        }
    }
}
